<?php

namespace app\api\controller;

use app\common\controller\Api;

class Topic extends Api
{
    protected $noNeedLogin = ['index','details'];
    protected $noNeedRight = '*';

    /**
     * 话题列表
     */
    public function index(){
        $topics=\app\common\model\Topic::where('status','normal')->order('weigh','DESC')->paginate();
        $this->success('话题列表',$topics);
    }
    /**
     * 话题详情
     */
    public function details($id){
        $topic=\app\common\model\Topic::where('status','normal')->find($id);
        if(!$topic){
           $this->error('话题不存在！');
        }
        $this->success('话题详情',$topic);
    }
}